<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 准备好一个区域 -->
    <div id="test"></div>

    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/javascript" src="../js/prop-types.js"></script>
    <script type="text/babel">
        // 1.创建组件
        class Person extends React.Component {
            // 构造器
            constructor(props) {
                super(props)
                console.log(props);
            }

            // 对标签属性进行类型,必要性限制 【isRequired必传】
            static propTypes = {
                name: PropTypes.string.isRequired
            }
            // 指定默认标签属性
            static defaultProps = {
                age: 30
            }

            render() {
                return (
                    <ul>
                        <li>姓名：{this.props.name}</li>
                        <li>性别：{this.props.sex}</li>
                        <li>年龄：{this.props.age}</li>
                    </ul>
                )
            }
        }


        // 2. 渲染组件到页面
        // ReactDOM.render(<Person name="余苗" age="20" sex="女" />, document.getElementById('test'))

        // ...扩展对象 只能用于标签使用
        let p = { name: "1111", sex: "女" }
        ReactDOM.render(<Person {...p} />, document.getElementById('test'))


    </script>
</body>

</html>